FROM ubuntu:20.04

WORKDIR /app

# 设置环境变量避免交互式提示
ENV DEBIAN_FRONTEND=noninteractive

# 设置代理

# 使用国内镜像源
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

# 安装 Python 和依赖
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    python3.8 \
    python3-pip \
    python3.8-dev \
    python3-setuptools \
    python3-wheel \
    gcc \
    libpcap-dev \
    bpfcc-tools \
    linux-headers-generic \
    libbpfcc \
    libbpfcc-dev \
    python3-bpfcc \
    build-essential \
    libelf-dev \
    clang \
    llvm \
    libbpf0 \
    libbpf-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# 创建 Python 软链接
RUN ln -sf /usr/bin/python3.8 /usr/bin/python && \
    ln -sf /usr/bin/pip3 /usr/bin/pip

# 设置 pip 镜像源
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

# 复制依赖文件
COPY requirements-intercept.txt .

# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements-intercept.txt

# 复制源代码
COPY src/ ./src/

# 设置环境变量
ENV PYTHONPATH=/app
ENV HOST=0.0.0.0
ENV PORT=5555
ENV PYTHONUNBUFFERED=1

# 暴露端口
EXPOSE 5555

# 清除代理设置


# 启动命令
CMD ["python", "src/main_intercept.py"]
